//
//  RegisteredViewController.m
//  豆瓣zlw
//
//  Created by lanou3g on 16/1/9.
//  Copyright © 2016年 zlw. All rights reserved.
//

#import "RegisteredViewController.h"
#import <AVOSCloud/AVOSCloud.h>
#import <MBProgressHUD.h>
#import "LoginViewController.h"
@interface RegisteredViewController ()<UITextFieldDelegate>

@end

@implementation RegisteredViewController

- (void)viewDidLoad
{
    self.RgestUserName.delegate = self;
    self.RestUserSurePaessWord.delegate = self;
    [super viewDidLoad];
    [self.HUD hide:YES];
    //指定目标(告诉程序要修改哪个账号中的哪个工程里的数据)
    [AVOSCloud setApplicationId:@"MsOHnv9Rb92SoX3Nsg7PtyU8-gzGzoHsz"
                      clientKey:@"LRnkEy80UsCHlaaprsehfX1E"];
    
    
}
- (IBAction)RegisteredSucess:(UIButton *)sender
{
    AVUser *user=[AVUser user];
    user.username=self.RgestUserName.text;
    user.password=self.RgestUserPassWord.text;
    [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (succeeded)
        {
            
            UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"提示信息" message:@"注册成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
            [alert show];

 

            [self.navigationController popViewControllerAnimated:YES];
           
          
        }else
        {
            UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"提示信息" message:@"注册失败,再输入一次" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
            [alert show];
            
            
         
        }
    }];

    
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.RgestUserName resignFirstResponder];
    [self.RgestUserPassWord resignFirstResponder];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
